/*
 * @Descripttion: 辅助方法
 * @version:
 * @Author: yangzhihao
 * @Date: 2021-07-09 16:58:06
 * @LastEditors: yangzhihao
 * @LastEditTime: 2021-07-14 15:14:28
 */
const toString = Object.prototype.toString

// val is Date 类型保护，保证val是Date类型
export function isDate(val: any): val is Date {
  return toString.call(val) === '[object Date]'
}

export function isObject(val: any): val is object {
  return toString.call(val) === '[object Object]'
}

// 将from的属性都扩展到to中
export function extend<T, U>(to: T, from: U): T & U {
  for (const key in from) {
    ;(to as T & U)[key] = from[key] as any
  }
  return to as T & U
}
